package top.scauwlt.registry.zk;

import org.apache.curator.framework.CuratorFramework;
import top.scauwlt.registry.ServiceRegistry;
import top.scauwlt.registry.zk.util.CuratorUtils;

import java.net.InetSocketAddress;

/**
 * @Author wmm
 * @Date 2022/7/25 13:23
 */
public class ZkServiceRegistryImpl implements ServiceRegistry {
    @Override
    public void registerService(String rpcServiceName, InetSocketAddress inetSocketAddress) {
        String servicePath = CuratorUtils.ZK_REGISTER_ROOT_PATH + "/" + rpcServiceName + inetSocketAddress.toString();
        CuratorFramework zkClient = CuratorUtils.getClient();
        CuratorUtils.createEphemeralNode(zkClient, servicePath);
    }
}
